package org.dei.perla.rockfall.gui.queryforge.panels;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.dei.perla.rockfall.gui.queryforge.IllegaParamValueException;
import org.dei.perla.rockfall.gui.queryforge.ReadableStatusPanel;

public class ThresholdZPanel extends ReadableStatusPanel {

	private JTextField jText3;
	
	public ThresholdZPanel(String title) {
		super(title);
	}

	@Override
	public int getStatus() throws IllegaParamValueException {
		try{
			int result = Integer.parseInt(jText3.getText());
			if(result > 65535)
				throw new IllegaParamValueException("Parametro impostato troppo elevato per thupz (< 65535)");
			return result;
		}catch(NumberFormatException e){
			throw new IllegaParamValueException("Parametro impostato troppo elevato per thupz (< 65535)");
		}

	}

	@Override
	public void setStatus(int stato) {
		jText3.setText(Integer.toString(stato));
	}

	@Override
	protected void setupInternalComponents() {
		
		//Primo blocco di scelte
		
		jText3 = new JTextField();
		jText3.setColumns(10);
		JLabel jlabel3 = new JLabel("Soglia asse Z");
		JPanel jpanel3 = new JPanel();
		jText3.setText("0");
		BoxLayout layout3 = new BoxLayout(jpanel3, BoxLayout.X_AXIS);
		jpanel3.add(jlabel3);
		jpanel3.add(jText3);
		
		//aggiungo tutti i blocchi
		this.add(jpanel3);
		
	}

}
